Calculate the number of days/weeks/months/years since a given date

Calculate the number of days/weeks/months/years since a given date

To calculate the number of days/weeks/months/years since a given date you use the following Temporal Since functions: Temporal Days Since, Temporal Weeks Since, Temporal Months Since, and Temporal Years Since.

The calculation stops by a given (exclusive) end date.

What do you want to do?

Calculate the number of days since a given date

Calculate the number of weeks since a given date

Calculate the number of months since a given date

Calculate the number of years since a given date

Calculate the weekdays in a given time period

Calculate a specific day in a month for a given time period

Calculate the number of days since a given date

To calculate the number of full days since a given date, you use the Temporal Days Since function. Note that this function will return a number variable that varies every day. The function has the following syntax:

 

For example, to determine the number of days since it has rained, you would write this rule in Word:

the number of days since it has rained = TemporalDaysSince(the date of the most recent rainfall,the current date)

 

The function returns a temporal value with the number of days incrementing on the date of each daily change point. Where 'the date of the most recent rainfall' (p6) is 15 May 2007, the calculation of 'the number of days since it has rained' (p5) is shown in the diagram below:

Calculate the number of weeks since a given date

To calculate the number of full weeks since a given date, you use the Temporal Weeks Since function. Note that this function will return a number variable that varies every week. The function has the following syntax:

 

For example, to determine the number of weeks in the assessment period where the start date is 12 March 2007 and the end date is 11 April 2007 you would write this rule in Word:

the number of weeks in the assessment period = TemporalWeeksSince(2007-03-12,2007-04-11)

 

The function returns a temporal value with the number of weeks incrementing on the date of each weekly change point. This is shown in the diagram below (p7 is 'the number of weeks in the assessment period'):


Calculate the number of months since a given date

To calculate the number of full months since a given date, you use the Temporal Months Since function. Note that this function will return a number variable that varies every month. The function has the following syntax:

 

For example, to determine the number of months a mobile phone contract has been in effect, you would write this rule in Word:

the number of months the mobile phone contract has been in effect = TemporalMonthsSince(the start date of the mobile phone contract,the current date)

 

The function returns a temporal value with the number of months incrementing on the date of each monthly change point. NOTE: Where the supplied date is after the 28th day of the month, and a subsequent month has fewer days than the supplied month, the change point for the anniversary month will be created on the last day of that month. For example, if the supplied date is 28, 29, 30 or 31 January 2007, the first change point will be 28 February 2007.

 

The earlier example is shown in the diagram below where 'the start date of the mobile phone contract' (p4) is 31 August 2006, and the current date is 20 December 2006 (p3 is 'the number of months the mobile phone contract has been in effect'):


Calculate the number of years since a given date

To calculate the number of full years since a given date, you use the Temporal Years Since function. Note that this function will return a number variable that varies every year. The function has the following syntax:

 

For example, to determine the child's age up to the child's fifth birthday, you would write this rule in Word:

the child's age = TemporalYearsSince(the child's date of birth,the child’s fifth birthday)

 

The function returns a temporal value with the number of years incrementing on the date of each annual change point. This is shown in the diagram below where 'the child's date of birth' (p2) is 03 October 2003 (p1 is 'the child's age', and p8 is 'the child's fifth birthday'):


Calculate the weekdays in a given time period

The Temporal Is Weekday function returns true on dates that are weekdays and false on dates that are weekends from the specified start date (inclusive) to the end date (exclusive). Note that this function will return uncertain outside of the date range. The syntax for this function is:

 

For example, the Temporal Is Weekday function could be used to determine if an applicant is receiving money on a given day when that person is receiving money each weekday between 1 July 2006 and 15 July 2006. In Word you would write this rule as:

the applicant receives money if

TemporalIsWeekday(2006-07-01, 2006-07-15)

 

The function returns a value of true for dates that are weekdays and false for the dates that are weekends:

Calculate a specific day in a month for a given time period

The Temporal Once Per Month function returns true if the day is equal to the day-of-month parameter and false on all other days of the month from the specified start date (inclusive) to the end date (exclusive). Note that this function will return uncertain outside of the date range. When the day-of-month exceeds the number of days in the current month, the value is true on the last day of that month. Therefore the function returns a value that is true exactly one day per month. The syntax for this function is:

 

For example, the Temporal Once Per Month function could be used to calculate the allowance given to an applicant who is receiving an allowance on the 15th of every month between 1 July 2006 and August 31, 2006. In Word you would write this rule as:

the applicant receives an allowance if

TemporalOncePerMonth(2006-07-01, 2006-08-31, 15)

 

The function returns a value of true for dates that are equal to the specified day of the month and false for all other dates: